package com.example.designPattern.singleton;


//线程安全（饿汉模式，变种） -- 静态代码块 与 HungrySafeSingleton 一种
public class HungrySafeStaticCodeBlockSingleton {
    /**
     *类变量在类准备阶段就初始化了然后放在<clinit>构造方法中，
     *一旦外部调用了静态方法，那么就会初始化完成。
     */
    private static HungrySafeStaticCodeBlockSingleton instance;
    static {
           instance = new HungrySafeStaticCodeBlockSingleton();
        }
    private HungrySafeStaticCodeBlockSingleton(){}
    public static synchronized HungrySafeStaticCodeBlockSingleton getInstance(){
        return instance;
    }
}
